﻿using ReflectionStudio.Core.Events;
using System;
using System.Data;
using System.Windows;
using System.Windows.Data;
using WPFExcelReport.Helpers;
using System.ComponentModel;
using System.Windows.Controls;
namespace WPFExcelReport
{
    public partial class UQP : UserControl
    {
        #region ==QPLAN===========
        public static readonly DependencyProperty QPLANProperty = DependencyProperty.Register("QPLAN",
            typeof(string), typeof(UQP),
            new FrameworkPropertyMetadata("", FrameworkPropertyMetadataOptions.BindsTwoWayByDefault, OnQPLANChanged));
        public string QPLAN
        {
            get
            {
                return (string)GetValue(QPLANProperty);
            }
            set
            {
                SetValue(QPLANProperty, value);
                LOADQP();
            }
        }
        private static void OnQPLANChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
        {
            var src = sender as UQP;
            if (src != null)
            {
                src.QPLAN = (string)e.NewValue;
            }
        }
        #endregion
        public UQP()
        {
            if (DesignerProperties.GetIsInDesignMode(this))
                return;
            InitializeComponent();
        }
        public void LOADQP()
        {
            cROOT.Children.Clear();                
            switch (QPLAN)
            {
                case "SM000001":
                    UQPSM1 UQPSM1 = new UQPSM1();
                    cROOT.Children.Add(UQPSM1);
                    break;
                case "YM000001":
                    UQPYM1 UQPYM1 = new UQPYM1();
                    cROOT.Children.Add(UQPYM1);
                    break;
                case "XS000001":
                    UQPXS1 UQPXS1 = new UQPXS1();
                    cROOT.Children.Add(UQPXS1);
                    break;
                case "BX000001":
                    UQPBX1 UQPBX1 = new UQPBX1();
                    cROOT.Children.Add(UQPBX1);
                    break;
            }
        }
    }
}
